﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using HFController;
using HFController.Public;
using System.Web.SessionState;
namespace HFWebApp.AjaxSource
{
    /// <summary>
    /// AddArticle 的摘要说明
    /// </summary>
    public class AddArticle : IHttpHandler, IRequiresSessionState
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            BagePages bp = new BagePages();
            System.Web.HttpPostedFile fileUpload2 = context.Request.Files["Files"];
            HTMLUPFileClass upFile = new HTMLUPFileClass();
            upFile.FileRenameMethod = 1;
            string PicTitle = "";
            if (upFile.HTMLUpLoad(fileUpload2))
            {
                PicTitle = upFile.FilePath;
            }
            string title = bp.GetAll("title");
            string content = bp.GetAll("content");
            string articletypeid = bp.GetAll("articletypeid");
            HFModel.ResultModel result = new HFModel.ResultModel();
            result = ArticleController.getController().doAddArticle(title, articletypeid, content, PicTitle);
            if (result.isTrue)
            {
                context.Response.Write("<script>alert('" + result.Message + "');location='/lawyeruser/lc_ArticleList.aspx';</script>");
            }
            else {
                context.Response.Write("<script>alert('" + result.Message + "');location='/lawyeruser/lc_AddArticle.aspx';</script>");
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}